package optimizers.ganeat.oscillator.faststrong;

import java.util.Map;

import javax.swing.JPanel;
import javax.swing.JProgressBar;

import org.w3c.dom.Element;

import common.RunStatus;

import fitness.FastStrongOscillatorFitness;
import fitness.Fitness;

import optimizers.commons.RunConfig;
import optimizers.ganeat.GA;
import optimizers.ganeat.Individual;
import optimizers.ganeat.Node;
import optimizers.ganeat.Constants;
import optimizers.ganeat.math.IndividualMath;

public class GAFSO extends GA {
	String initIndiv = "Node gens:\r\n" + " a 45.427 0\r\n" + " b 34.947 0\r\n"
			+ " c 50 0\r\n" + " Iac 0.4766 10\r\n" + "Connection gens:\r\n"
			+ " 1 a->a false 3.7959\r\n" + " 2 a->c true 13.8931\r\n"
			+ " 3 c->b true 12.0435\r\n" + " 6 b->Iac true 28.9895\r\n"
			+ "Exo: 0.6818\r\n" + "Pol: 18.6541\r\n" + "Nick: 2.6789";

	/*
	 * @Override public Individual getInitialIndividual() { IndividualFSO indiv
	 * = new IndividualFSO(innovations, nodeNames, -1, 0);
	 * indiv.nodeGenes.add(new Node("a", 89.92, Node.SIMPLE_SEQUENCE));
	 * indiv.nodeGenes.add(new Node("b", 70, Node.SIMPLE_SEQUENCE));
	 * indiv.nodeGenes.add(new Node("Iaa", Constants.defaultNodeParam,
	 * Node.INHIBITING_SEQUENCE)); indiv.nodeGenes.add(new Node("Ibb",
	 * Constants.defaultNodeParam, Node.INHIBITING_SEQUENCE));
	 * indiv.addConnection(indiv.getNode("a"), indiv.getNode("Iaa"), true, 30);
	 * indiv.addConnection(indiv.getNode("a"), indiv.getNode("a"), true, 5);
	 * indiv.addConnection(indiv.getNode("b"), indiv.getNode("b"), true, 5);
	 * indiv.addConnection(indiv.getNode("b"), indiv.getNode("Ibb"), true, 10);
	 * return indiv; }
	 */

	public GAFSO(RunConfig config, String initIndiv, JPanel panelFitness,
			JPanel panelSpecies, JPanel panelIndiv, RunStatus runStatus,
			JProgressBar progressBar, Element fitnessElement) {
		super(config, panelFitness, panelSpecies, panelIndiv, runStatus,
				progressBar, fitnessElement);
		this.initIndiv = initIndiv;
	}

	/*
	 * @Override public Individual getInitialIndividual() { IndividualFSO indiv
	 * = new IndividualFSO(innovations, nodeNames, -1, 0);
	 * indiv.nodeGenes.add(new Node("a", 50, Node.SIMPLE_SEQUENCE));
	 * indiv.nodeGenes.add(new Node("b", 50, Node.SIMPLE_SEQUENCE));
	 * indiv.nodeGenes.add(new Node("c", 50, Node.SIMPLE_SEQUENCE));
	 * indiv.nodeGenes.add(new Node("d", 50, Node.SIMPLE_SEQUENCE));
	 * indiv.nodeGenes.add(new Node("e", 50, Node.SIMPLE_SEQUENCE));
	 * 
	 * indiv.addConnection(indiv.getNode("a"), indiv.getNode("a"), true, 21);
	 * indiv.addConnection(indiv.getNode("b"), indiv.getNode("b"), true, 20);
	 * indiv.addConnection(indiv.getNode("c"), indiv.getNode("c"), true, 20);
	 * indiv.addConnection(indiv.getNode("d"), indiv.getNode("d"), true, 20);
	 * indiv.addConnection(indiv.getNode("e"), indiv.getNode("e"), true, 20);
	 * indiv.addConnection(indiv.getNode("a"), indiv.getNode("b"), true, 10);
	 * indiv.addConnection(indiv.getNode("b"), indiv.getNode("c"), true, 10);
	 * indiv.addConnection(indiv.getNode("c"), indiv.getNode("d"), true, 10);
	 * indiv.addConnection(indiv.getNode("d"), indiv.getNode("e"), true, 10);
	 * indiv.addConnection(indiv.getNode("e"), indiv.getNode("a"), true, 10);
	 * return indiv; }
	 */
	@Override
	public Individual getInitialIndividual() {
		return new IndividualFSO(innovations, nodeNames, -1, 0, config,
				initIndiv);
	}

	@Override
	public Individual getNewIndividual(Map<String, Integer> innovations2,
			Map<String, String> nodeNames2, int i, int j) {
		return new IndividualFSO(innovations2, nodeNames2, i, j, config);
	}

	@Override
	public String getProblemName() {
		return "FastStrongOscillator";
	}

}
